#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    bool backspaceCompare(string s, string t) {
        string s1, t1;
        int si = 0, ti = 0;
        while (si < s.size())
        {
            if (s[si] != '#') s1.push_back(s[si]);
            else
            {
                if (s1.size()) s1.pop_back();
            }
            si++;
        }
        while (ti < t.size())
        {
            if (t[ti] != '#') t1.push_back(t[ti]);
            else { if (t1.size()) t1.pop_back(); }
            ti++;
        }
        if (s1 == t1) return true;
        else return false;
    }
};